package com.falcon.modules.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.falcon.modules.domain.dto.User;
import com.falcon.modules.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import org.springside.modules.utils.mapper.JsonMapper;

@RestController
@RequestMapping("/test")
public class TestContoller {

    @Autowired
    private IUserService userService;

    @RequestMapping("/index")
    public ModelAndView index(String name) {
        ModelAndView modelAndView = new ModelAndView("index.html.bak");
        Page page = new Page(1, 10);
        Page<User> userPage=userService.selectPage(page,null);

        System.out.println("============="+JsonMapper.INSTANCE.toJson(userPage));

        modelAndView.addObject("user", userService.selectPage(page).getRecords().get(0));
        return modelAndView;
    }
}
